//unix includes from mForms
uses x,xlib,xutil;
procedure TApplication.ProcessMessages;
var
    EV:TXEvent;
    i: Integer;
begin
 XNextEvent(XWinDisplay,@Ev);
 //writeln('Event ',ev._type);
 for i:=0 to AllWnds.Count-1 do
   if TWinControl(AllWnds.Items[i]).Handle=ev.xany.window then
   begin
     TControl(AllWnds.Items[i]).ProcessEvent(@Ev);
   end;
end;
procedure TForm.SetCaption(AValue: AnsiString);
var TxtProp:TXTextProperty;
    ch:PChar;
begin
  inherited SetCaption(AValue);
  if FHandle=0 then exit;
  ch:=PChar(AValue);
  {$ifdef FPC}
  Xutf8TextListToTextProperty(XWinDisplay,@ch,1,XUTF8StringStyle,@TxtProp);
  {$else}
  XStringListToTextProperty(@ch,1,@TxtProp);//TODO encoding
  {$endif}
  XSetWMName(XWinDisplay,FHandle,@TxtProp);
end;

constructor TForm.Create(AOwner: TComponent);
var
  event_mask: Integer;
begin
  inherited Create(AOwner);
  FSpecificHandling:=true;
  AllWnds.Add(self);
  if FWidth=0 then FWidth:=100;
  if FHeight=0 then FHeight:=100;

    FHandle:=
    XCreateSimpleWindow(
    XWinDisplay,
    XRootWindow(XWinDisplay,XDefaultScreen(XWinDisplay)),
    FLeft,FTop,
    FWidth,FHeight,
    2,COLOR_ACTIVEBORDER,COLOR_BACKGROUND);

    event_mask:=KeyPressMask or KeyReleaseMask or EnterWindowMask or
      LeaveWindowMask or PointerMotionHintMask or Button1MotionMask or Button2MotionMask
      or Button3MotionMask or VisibilityChangeMask or StructureNotifyMask or ButtonPressMask or
      ButtonReleaseMask;
    XSelectInput(XWinDisplay,FHandle,event_mask);
end;

destructor TForm.Destroy;
begin
  inherited Destroy;
end;
procedure PlatformInit_mForms;{$ifdef FPC}inline;{$endif}
begin
end;
